Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle None for signal_id in GetValue endpoint #123

Merged

Conversation

engelmi
Copy link
Contributor

@engelmi engelmi commented Dec 30, 2024

Description of bug and proposed fix

Currently, calling the GetValue endpoint with an empty body will cause the databroker to panic since unwrap is called on the signal_id option - which is None in that case. In order to prevent the server-side panic, a simple none check is performed before calling unwrap.

How to reproduce the bug

Example script to trigger the databroker to panic:

import grpc

from kuksa.val.v2.val_pb2 import GetValueRequest
from kuksa.val.v2.val_pb2_grpc import VALStub

with grpc.insecure_channel("0.0.0.0:55555") as channel:
    VALStub(channel).GetValue(GetValueRequest())

Running this script should result in the panic on the

# ...
2024-12-27T15:51:55.842868Z  INFO databroker::grpc::server: Authorization is not enabled.
thread 'tokio-runtime-worker' panicked at databroker/src/grpc/kuksa_val_v2/val.rs:856:37:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.15%. Comparing base (a67f4e6) to head (b81b797).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
databroker/src/grpc/kuksa_val_v2/val.rs 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   60.06%   60.15%   +0.08%     
==========================================
  Files          33       33              
  Lines       16168    16191      +23     
==========================================
+ Hits         9712     9739      +27     
+ Misses       6456     6452       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Currently, calling the GetValue endpoint with an empty body
will cause the databroker to panic since unwrap is called
on the signal_id option - which is None in that case. In
order to prevent the server-side panic, a simple none check
is performed before calling unwrap.

Signed-off-by: Michael Engel <[email protected]>
@engelmi engelmi force-pushed the get-value-handle-signal-id-none branch from d5baff3 to b81b797 Compare January 2, 2025 13:42
Copy link
Contributor

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your (first (of many?)) contribution.

lgtm 🕹️

@SebastianSchildt SebastianSchildt merged commit 86ed421 into eclipse-kuksa:main Jan 7, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants